<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/salesReport.do?action=shippingreport" />
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
 <%
     String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
     String userTypeCustomer = Constants.USER_TYPE_CUSTOMER + "";
     String userTypeSalesPerson = Constants.USER_TYPE_SALES_PERSON + "";
 %>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<!-- Added by Krishna Prasad on 10 May 2004, to get From and To Date Validation function -->
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></SCRIPT>

<script>
var dateElement = "";
    function openCalendar(dateValue)
    {
	dateElement = dateValue;
  	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
  	newWindow.moveTo(550,180);
  	newWindow.focus();
    }
	function assignDate(passedValue)
    {
	dateElement.value=passedValue;
	window.focus();
    }

<%-- Added by Krishna Prasad on 10 May 2004 for Validating the 'To' and 'From' Dates --%>
function validateFromAndToDates()
{
    formdoc = document.shipReport;
    errMsg = '';

    var pa	= document.getElementById("errors")

    if(chkDate(formdoc.datefrom.value,'From-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.datefrom.focus();
        return false;
    }

    if(chkDate(formdoc.dateto.value,'To-Date','N') == false)
    {
        pa.innerHTML = errMsg;
        formdoc.dateto.focus();
        return false;
    }


    if(formdoc.datefrom.value!='' && formdoc.dateto.value!='')
    {
        if (!validateDateOut(formatDateAsMMDDYYYY(formdoc.datefrom.value),formatDateAsMMDDYYYY(formdoc.dateto.value)))
        {
            pa.innerHTML = "To Date cannot be less than From Date";
            formdoc.dateto.focus();
            return false;
        }
    }
    return true;
}
function dateRange( fileType )
{
var d = new Date();
		var day = d.getDate();
		var month = d.getMonth()+1;
		var year = d.getFullYear();
		var hour = d.getHours();
		var min = d.getMinutes();
		var sec = d.getSeconds();

		var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;

        var success;
        success = true;
		success = validateFromAndToDates();
		if(success == false)
        {
           return false;
        }
        var partNumberObj = document.shipReport.product;
        var processstepId = "";
        var count = 0;
        for( var i = 0; i < partNumberObj.length; i++ )
        {
            if( partNumberObj.options[i].selected )
            {
                count++;
                if ( processstepId != '' )
                {
                    processstepId = processstepId + "," + partNumberObj.options[i].value;
                }
                else
                {
                    processstepId = partNumberObj.options[i].value;
                    if( partNumberObj.options[i].value == '0' )
                    {
                        break;
                    }
                }
            }
        }
        if ( processstepId == '')
        {
            processstepId = "0";
        }
        if( count > 10)
        {
            pa.innerHTML = "<li>Please select upto 10 Products only";
            return;
        }
        else
        {
            document.shipReport.prompt0.value = processstepId;
        }

    if (document.shipReport.salesorderno.value=='')
        document.shipReport.prompt1.value='0';
    else
        document.shipReport.prompt1.value = document.shipReport.salesorderno.value;

    if (document.shipReport.customer.value=='')
        document.shipReport.prompt2.value='0';
    else
        document.shipReport.prompt2.value = document.shipReport.customer.value;

    <logic:equal value="<%=userTypeSalesPerson%>" name="user" property="userType" scope="session">
    if  ( document.shipReport.prompt2.value== 0 )
    {
        var element = document.shipReport.customer;
        var customerIds = "0";
        for( var i = 0 ; i < element.length; i++ )
        {
            if ( customerIds != '' && customerIds != "0" )
            {
                customerIds = customerIds+","+element.options[i].value;
            }
            else
            {
                customerIds = element.options[i].value;
            }
        }

        document.shipReport.prompt2.value= customerIds;
    }
    </logic:equal>

    if (document.shipReport.datefrom.value=='')
        document.shipReport.prompt3.value='0';
    else
        document.shipReport.prompt3.value = document.shipReport.datefrom.value;

    if (document.shipReport.dateto.value=='')
        document.shipReport.prompt4.value='0';
    else
        document.shipReport.prompt4.value = document.shipReport.dateto.value;

    var period="";
    var cat="";
    var tp= "";


for (counter = 0; counter < shipReport.periodically.length; counter++)
{
    if (shipReport.periodically[counter].checked)
    {
        period = shipReport.periodically[counter].value;
    }
}
    document.shipReport.prompt5.value = document.shipReport.orderType.value;
    document.shipReport.prompt6.value = period;
    document.shipReport.prompt7.value = "Crystal";
    document.shipReport.prompt8.value = defaultPrompt;

    document.shipReport.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Shipped/Shipment_Report.rpt";

    if( fileType == 2 )
    {
        var prompt0 = document.shipReport.prompt0.value;
        var prompt1 = document.shipReport.prompt1.value;
        var prompt2 = document.shipReport.prompt2.value;
        var prompt3 = document.shipReport.prompt3.value;
        var prompt4 = document.shipReport.prompt4.value;
        var prompt5 = document.shipReport.prompt5.value;
        var prompt6 = period;
        var prompt7 = "xlreport";
        var prompt8 = document.shipReport.prompt6.value; // for default prompt

        var newWindow;
        var url = '<%=chipTracContext%>/customerReport.do?action=shipmentxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8;
        newWindow = window.open ( url, 'ShipmentReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
    }
    else if( fileType == 3 )
    {
        var prompt0 = document.shipReport.prompt0.value;
        var prompt1 = document.shipReport.prompt1.value;
        var prompt2 = document.shipReport.prompt2.value;
        var prompt3 = document.shipReport.prompt3.value;
        var prompt4 = document.shipReport.prompt4.value;
        var prompt5 = document.shipReport.prompt5.value;
        var prompt6 = period;
        var prompt7 = "xlreport";
        var prompt8 = document.shipReport.prompt6.value; // for default prompt

        var newWindow;
        var url = '<%=chipTracContext%>/customerReport.do?action=shipmentcsv&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8;
        newWindow = window.open ( url, 'ShipmentReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
    }
    else
    {
        document.shipReport.submit();
        return true;
    }
}


function installNPViewer()
{
    var url = '<%=chipTracContext%>/jsp/includes/others/npviewer.exe';
    newWindow = window.open ( url, 'InstallNPViewer', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=50,height=50,resizable=no');
}
function initLoad(){
    <%!
      String fromDate = null;
      String toDate = null;
    %>
    <%
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar = Calendar.getInstance();
        GregorianCalendar gc = new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        gc.add(GregorianCalendar.YEAR, -1);
        Date d = gc.getTime();
        fromDate = sdf.format(d);
        SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy");
        Calendar calendar1 = Calendar.getInstance();
        GregorianCalendar gc1 = new GregorianCalendar(calendar1.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
        gc1.add(GregorianCalendar.DATE, 1);
        Date d1 = gc1.getTime();
        toDate = sdf1.format(d1);
    %>
    document.getElementById("datefrom").value = "<%=fromDate%>";
    document.getElementById("dateto").value = "<%=toDate%>";
}
</script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="initLoad();">

<!-- Top Header Start-->

    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>
<!-- Top Header End-->


<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/sales_report_menu.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/sales/external_reports_menu.jsp" %>
    </logic:notEqual>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">
<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>

    <table border="0" width="85%" align=center cellspacing="4" cellpadding="2">
    <tr><td colspan="6" align="center" class="NArialW">Shipment Reports</td></tr>
    <tr>
        <td colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5>
            <form name="shipReport" method="post">
            <input type="hidden" name="prompt0">
            <input type="hidden" name="prompt1">
            <input type="hidden" name="prompt2">
            <input type="hidden" name="prompt3">
            <input type="hidden" name="prompt4">
            <input type="hidden" name="prompt5">
            <input type="hidden" name="prompt6">
            <input type="hidden" name="prompt7">
            <input type="hidden" name="prompt8">
        </td>
    </tr>
    <tr>
        <td colspan="6">
            <b><font face="Verdana" size="-5" align="center" color="#ff0000" id="errors"></font></b>
        </td>
    </tr>

    <tr>
        <td width="20%" valign="top"><font class="NArialL" >Customer :</font></td>
        <td width="20%" valign="top"><font class="NArialL" >
            <select size="1" name="customer" class="txfield" style="width:170px">
                    <logic:iterate id="customerSelectList" name="customerSelectList">
                        <logic:notEqual name="customerSelectList" value="null">
                            <option value = "<bean:write name="customerSelectList" property="value"/>" >
                                <bean:write name="customerSelectList" property="label"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
            </select>
            </font>
        </td>
        <td width="5%">&nbsp;&nbsp;</td>
        <td width="21%" valign="top" norap>
            <font class="NArialL"><bean:message key="label.mfgPartNumber" /> :</font>
        </td>
        <td width="20%"><font class="NArialL" valign="top">
            <select size="5" name="product" class="txfield" style="width:170px" multiple="true">
                <option value="" selected>All Products</option>
                    <logic:iterate id="mktgPartNumberSelectList" name="mktgPartNumberSelectList">
                        <logic:notEqual name="mktgPartNumberSelectList" value="null">
                            <option value = "<bean:write name="mktgPartNumberSelectList" property="productId"/>" >
                                <bean:write name="mktgPartNumberSelectList" property="manufacturingPartNo"/>
                            </option>
                        </logic:notEqual>
                    </logic:iterate>
            </select>
            </font>
        </td>
        <td width="8%">&nbsp;</td>
    </tr>

	<tr>
        <td width="20%"><font class="NArialL">Sales Order No :</font></td>
        <td width="20%"><font class="NArialL">
            <input type="text" name="salesorderno" class="txfield" style="width:170px"></font>
      	</td>
	    <td width="5%">&nbsp;</td>
        <td width="19%"><font class="NArialL">Category :</font></td>
        <td width="20%">
            <select name="orderType" class="txfield" style="width:170px">
                <option value="1" selected >Regular</option>
                <option value="0">Sample</option>
                <option value="2">Consignment</option>
            </select>
        </td>
	    <td width="8%">&nbsp;</td>
    </tr>

    <tr>
        <td width="17%" class="NArialL">From-Date : </td>
        <td width="20%" class="NArialL">
      	    <input type="text" name="datefrom" size="12" class="txfield">
            <a href="javascript:openCalendar(document.shipReport.datefrom)">
        <img onMouseOver="window.status='Click to Select From Date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select From Date"
        src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=17 width=17></a></TD>
        <td width="8%">&nbsp;</td>
        <td width="19%"><font class="NArialL">To-Date :</font></td>
        <td width="20%" class="NArialL">
      	    <input type="text" name="dateto" size="12" class="txfield">
            <a href="javascript:openCalendar(document.shipReport.dateto)">
        <img onMouseOver="window.status='Click to Select to Date';return true" onMouseOut="window.status='';return true" border="0" align='center' title="Click here to Select To Date"
        src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=17 width=17></a></TD>
    </tr>
	<tr><td colsapn=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
        <td colspan=6>
	    	<input type="radio" name="periodically" value="byMonth" checked>
	    		<font class="NArialL">By Month </font>&nbsp;&nbsp;&nbsp;&nbsp;
	    	<input type="radio" name="periodically" value="byQuarter">
	    		<font class="NArialL">By Quarter</font>&nbsp;&nbsp;&nbsp;&nbsp;
	    	<input type="radio" name="periodically" value="byYear">
	    		<font class="NArialL">By Year</font>
        </td>

    </tr>


    <tr><td colsapn=1><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td>
        <td colspan=4 valign="top" align="RIGHT">
            <%--<a class="NArialL" href="javascript:dateRange(3)" onMouseOver="window.status='Click here to Export to CSV';return true" onMouseOut="window.status='';return true" title='Click here to Export to CSV' >Export to CSV</a>--%>
            <a class="NArialL" href="javascript:dateRange(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
        </td>
    </tr>

	<tr>
      <td colspan=6 align=center><input type="image" onClick="javascript:return dateRange(1);"  border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true"onmouseout="window.status='';return true"title="Click here to Generate Report"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     <a href="javascript:document.shipReport.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true"title="Click here to Reset"></a>
    </tr>
    <tr>
        <td colspan=2 valign='top'>&nbsp;</td>
        <td colspan=4 align="center" >
            <a class="NArialL" href="javascript:installNPViewer()" onMouseOver="window.status='Click here to install Activex Control for Reports';return true" onMouseOut="window.status='';return true" title='Click here to install Activex Control for Reports' >
                Click here to install Activex Control for Reports
            </a>
        </td>
    </tr>
  </table>
  <%--
    <tr>
        <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'></td>
        <td colspan=3 align="right" >&nbsp;</td>
    </tr>--%>
<!-- till here -->
<BR><BR><BR></TD>

<%--<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>--%>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</form>
</BODY>
</HTML>
